/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package semantic.resources;

import java.io.*;
import java.util.Scanner;

/**
 *
 * @author Yan Lin
 */
public class FileRead {

    private static void readMultipleFilesFromADirectory() {
        File directory = new File("C:/Users/Yan Lin/Desktop/As3DataSetUpdate");

        // just to double check that this is a directory
        if (directory.isDirectory()) {
            File[] files = directory.listFiles();
            System.out.println("About to read "
                    + files.length
                    + " within the directory " + directory.getAbsolutePath());
            for (File file : files) {
                System.out.println("\n** About to read a file "
                        + file.getName() + " **");
                try {
                    Scanner scanner = new Scanner(file);
                    while (scanner.hasNext()) {
                        String fileContents = scanner.next();
                        System.out.println("The file contents are:");
                        System.out.println(fileContents);
                    }
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
